var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var schemaPlayer = new Schema({
  account_id: String,
  names: [String],
  match_ids: [String]
});

var schemaMatch = new Schema({
  match_id: String,
  ping_quality: String,
  season_state: String,
  start_time: Date,
  end_time: Date,
  is_eventMode: Boolean,
  is_customGame: Boolean,
  team_size: Number,
  weather_id: String,
  camera_view_behaviour: String,
  map_name: String,
  players: [{
    name: String,
    team_id: Number,
    account_id: String
  }]
});


var schemaEvent = new Schema({
  _T: String,
  _D: Date,
  match_id: String,
  // raw:Object
});

var schemaPlayerPerformanceIndicator = new Schema({
  account_id: { type: String, index: true },
  match_id: { type: String, index: true }
}, { strict: false })

var schemaPlayerCharacters = new Schema({
  account_id: { type: String, index: true },
  match_id: { type: String, index: true },
  arrayOfCharacters: Array// Array<{time:Date,character:Object,in_event:String,info:any}>>
}, { strict: false });



var Player = mongoose.model("Player", schemaPlayer);
var Match = mongoose.model("Match", schemaMatch);
var Event = mongoose.model("Event", schemaEvent);

var PlayerPerformanceIndicator = mongoose.model("PlayerPerformanceIndicator", schemaPlayerPerformanceIndicator)
var PlayerCharacters = mongoose.model("PlayerCharacters", schemaPlayerCharacters)


module.exports = {
  Player,
  Match,
  Event,
  PlayerPerformanceIndicator,
  PlayerCharacters
}


